import { IsEmpty } from '@/utils/common';

/**
 * 检验记录查询【状态】可取值
 */
export function stateOptions() {
  return [
    {
      value: 0, //{ all: -1 },
      label: '全部'
    },
    {
      value: 1, //{ isChk: 2 },
      label: '已审核'
    },
    {
      value: 2, //{ isChk: 0 },
      label: '未审核'
    },
    {
      value: 3, //{ isChk: 1 },
      label: '已初审'
    },
    {
      value: 4, //{ isPrinted: 1 },
      label: '已打印'
    },
    {
      value: 5, //{ isPrinted: 0 },
      label: '未打印'
    },
    {
      value: 6, //{ isChk: 2, isPrinted: 1 },
      label: '已审核已打印'
    },
    {
      value: 7, //{ isChk: 1, isPrinted: 0 },
      label: '已审核未打印'
    },
    {
      value: 8, //{ isChk: 0, isPrinted: 1 },
      label: '未审核已打印'
    },
    {
      value: 9, //{ isChk: 0, isPrinted: 0 },
      label: '未审核未打印'
    },
    {
      value: 10, //{ isChk: 1, isPrinted: 1 },
      label: '初审已打印'
    },
    {
      value: 11, //{ isChk: 1, isPrinted: 0 },
      label: '初审未打印'
    }
  ];
}
/**
 * 检验记录右键菜单
 */
export function testListRightMenus(proxy: any, callback: any) {
  return {
    header: {
      options: [
        [
          { code: 'hideColumn', name: '隐藏列', disabled: false },
          {
            code: 'showAllColumn',
            name: '取消所有隐藏列',
            disabled: false
          }
        ]
      ]
    },
    body: {
      options: [
        [
          {
            code: 'Reload',
            name: '刷新',
            prefixIcon: 'vxe-icon-refresh',
            disabled: false
          },
          {
            code: 'Copy',
            name: '复制',
            prefixIcon: 'vxe-icon-copy',
            disabled: false
          },
          // {
          //   code: 'Edit',
          //   name: '编辑',
          //   prefixIcon: 'vxe-icon-edit',
          //   disabled: false
          // },
          {
            code: 'Delete',
            name: '删除',
            prefixIcon: 'vxe-icon-delete',
            disabled: false
          }
        ],
        [
          {
            code: 'DeleteMany',
            name: '批量删除',
            prefixIcon: 'vxe-icon-arrow-double-right',
            disabled: false
          },
          {
            code: 'FirstReviewMany',
            name: '批量初审',
            prefixIcon: 'vxe-icon-arrow-double-right',
            disabled: false
          },
          {
            code: 'ReviewMany',
            name: '批量审核',
            prefixIcon: 'vxe-icon-arrow-double-right',
            disabled: false
          },
          {
            code: 'PrintMany',
            name: '批量打印',
            prefixIcon: 'vxe-icon-arrow-double-right',
            disabled: false
          }
        ],
        [
          {
            code: 'FindRpt',
            name: '报告查询',
            prefixIcon: 'vxe-icon-file-pdf',
            disabled: false
          }
        ],
        [
          {
            code: 'CancelTest',
            name: '取消上机',
            prefixIcon: 'vxe-icon-undo',
            disabled: false
          }
        ],
        [
          {
            code: 'TRansToQc',
            name: '转质控',
            prefixIcon: 'vxe-icon-chart-radar',
            disabled: false
          }
        ],
        [
          {
            code: 'FlowChart',
            name: '标本闭环',
            prefixIcon: 'vxe-icon-fixed',
            disabled: false
          }
        ],
        [
          {
            code: 'ForceChker',
            name: '强制人工审核',
            prefixIcon: 'vxe-icon-user-fill',
            disabled: false
          }
        ],
        [
          {
            code: 'CaSignData',
            name: 'CA签名数据',
            prefixIcon: 'vxe-icon-user-fill',
            disabled: false
          }
        ]
      ]
    },
    visibleMethod: ({ options, column, row }: any) => {
      if (callback) {
        callback({ options, column, row });
      }
      return true;
    }
  };
}

/**
 * 检验记录列表顺序排序
 * @array 待排序的检验记录集合
 */
export function mainInfoSort(array: any[]) {
  array.forEach((a) => {
    if (a && !a.sortcode) {
      a['sortcode'] = '';
    }
    if (a && !IsEmpty(a.sampleNo)) {
      let s = a.sampleNo;
      s = s.replace(/a/g, '01');
      s = s.replace(/b/g, '02');
      s = s.replace(/c/g, '03');
      s = s.replace(/d/g, '04');
      s = s.replace(/e/g, '05');
      s = s.replace(/f/g, '06');
      s = s.replace(/g/g, '07');
      s = s.replace(/h/g, '08');
      s = s.replace(/i/g, '09');
      s = s.replace(/j/g, '10');
      s = s.replace(/k/g, '11');
      s = s.replace(/l/g, '12');
      s = s.replace(/m/g, '13');
      s = s.replace(/n/g, '14');
      s = s.replace(/o/g, '15');
      s = s.replace(/p/g, '16');
      s = s.replace(/q/g, '17');
      s = s.replace(/r/g, '18');
      s = s.replace(/s/g, '19');
      s = s.replace(/t/g, '20');
      s = s.replace(/u/g, '21');
      s = s.replace(/v/g, '22');
      s = s.replace(/w/g, '23');
      s = s.replace(/x/g, '24');
      s = s.replace(/y/g, '25');
      s = s.replace(/z/g, '26');
      s = s.replace(/A/g, '27');
      s = s.replace(/B/g, '28');
      s = s.replace(/C/g, '29');
      s = s.replace(/D/g, '30');
      s = s.replace(/E/g, '31');
      s = s.replace(/F/g, '32');
      s = s.replace(/G/g, '33');
      s = s.replace(/H/g, '34');
      s = s.replace(/I/g, '35');
      s = s.replace(/J/g, '36');
      s = s.replace(/K/g, '37');
      s = s.replace(/L/g, '38');
      s = s.replace(/M/g, '39');
      s = s.replace(/N/g, '40');
      s = s.replace(/O/g, '41');
      s = s.replace(/P/g, '42');
      s = s.replace(/Q/g, '43');
      s = s.replace(/R/g, '44');
      s = s.replace(/S/g, '45');
      s = s.replace(/T/g, '46');
      s = s.replace(/U/g, '47');
      s = s.replace(/V/g, '48');
      s = s.replace(/W/g, '49');
      s = s.replace(/X/g, '50');
      s = s.replace(/Y/g, '51');
      s = s.replace(/Z/g, '52');
      a['sortcode'] = s.padStart(20, '0');
    }
  });
  array.sort((a, b) => {
    return a['sortcode'] - b['sortcode'];
  });
  return array;
}

/**
 * 31天颜色值
 */
export function color31() {
  const temp = ['#ffff00', '#33ffff', '#ccffff', '#33ff00', '#ff6600', '#cc3300', '#663300', '#3333cc', '#FF8C00', '#FF6EB4', '#FF83FA', '#FF3E96', '#EE8262', '#9B30FF', '#A0522D', '#7B68EE', '#616161', '#0000AA', '#000099', '#6633cc', '#ff0066', '#cc00ff', '#990099', '#FFA07A', '#FF8247', '#FF6EB4', '#F08080', '#EE82EE', '#D02090', '#C0FF3E', '#9AC0CD'];
  return temp;
}
